const { Sequelize, sequelize, DataTypes } = require('../init.js')
const db_Name = 'vw_mp_users'

const vw_mp_users = sequelize.define(db_Name, {
	mp_uid: {
		type: DataTypes.UUID,
		allowNull: false,
		primaryKey: true,
		defaultValue: DataTypes.UUIDV1,
		unique: true,
		comment: "小程序账号id",
	},
	uid: {
		type: DataTypes.UUID,
		allowNull: true,
		validate: {
		  notEmpty: true,
		},
		comment: "普通账号id",
	  },
	email: {
		type: Sequelize.STRING
	},
	nickName: {
		type: Sequelize.STRING,
		allowNull: false,
		validate: {
			notEmpty: true
		}
	},
	password: {
		type: Sequelize.STRING,
		allowNull: true,
		validate: {
			notEmpty: true
		}
	},
	openid: {
		type: Sequelize.STRING,
		allowNull: true,
		validate: {
			notEmpty: true
		}
	},
	avatarUrl:{
		type: Sequelize.STRING,
		allowNull: true,
		validate: {
			notEmpty: true
		}
	},
	city:{
		type: Sequelize.STRING,
		allowNull: true,
		validate: {
			notEmpty: true
		}
	},
	province:{
		type: Sequelize.STRING,
		allowNull: true,
		validate: {
			notEmpty: true
		}
	},
	gender:{
		type: Sequelize.INTEGER,
		allowNull: true,
		validate: {
			notEmpty: true
		}
	},
})

vw_mp_users.sync({
	//  force: true 
	 alert: true 
}).then(() => {
	// 建表
	console.log(`${db_Name}表模型同步`)
})

module.exports = vw_mp_users
